package com.st.controller;

import com.st.activeMQ.listener.QueueListener;
import com.st.pojo.BookBean;
import com.st.service.AMQProductionService;
import javafx.scene.input.DataFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.jms.JMSException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.text.MessageFormat;
import java.util.Date;

@Controller
public class MqController {
    @Resource
    private AMQProductionService amqProductionService;

    @Resource
    private QueueListener queueListener;
    /**
     * MQ生产者，用户下单生产消息者
     */
    @RequestMapping(value = "/product")
    public void production() {
        //网络传输数据，参数需要序列化，BookBean类实现Serializable接口完成序列化
        BookBean bookBean = null;
        Date date = new Date();
        for (int i = 0; i < 12000; i++) {
            bookBean = new BookBean(i, "ActiveMQ测试插入数据"+i, 56.23, date);
            amqProductionService.sendMsg(bookBean);
        }
    }


}
